package com.daisuxia.payRoute;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.daisuxia.risk.service.IOutOrdersService;
import com.daisuxia.web.pojo.Repayment;
import com.daisuxia.web.pojo.User;
import com.daisuxia.web.pojo.UserCardInfo;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;

import static sun.net.www.protocol.http.AuthCacheValue.Type.Server;

/**
 * Created by dhl on 2017/5/18.
 */
//支付路由代理

public class PayRoute {
	//支付管理者
	private  PayManager payManager ;

	public PayRoute(IOutOrdersService outOrdersService){
		init(outOrdersService);
	}

	void init(IOutOrdersService outOrdersService){
		payManager = new PayManager();
		//第一个支付机构 rongbao
		IPayCommons iPayCommons1 = new RongBaoPay(outOrdersService);
		//第二个支付机构 rongbao
		IPayCommons iPayCommons2 = new BaofooPay(outOrdersService);


		//注册支付机构
		payManager.registerIPay(iPayCommons1,iPayCommons2);
	}
	/**
	 * 获取代扣信息
	 * @param Repayment re 借款信息
	 * @param User user 用户
	 * @param UserCardInfo userCardInfo 卡号
	 * @param transId 订单号
	 * @return
	 * @throws IOException
	 * @throws URISyntaxException
	 */
	public  Map getCutPay(Map map) throws IOException, URISyntaxException {

		return payManager.handleOrder(map);
	}

}
